package pcb.views.sharedAssets 
{
	import com.intel.service.HttpService;
	import com.intel.service.ServiceEvent;
	import com.intel.utils.Debugger;
	import flash.display.MovieClip;
	import flash.net.URLRequestMethod;
	import pcb.models.LocaleModel;
	import pcb.models.ModelLocator;
	
	/**
	 * ...
	 * @author Fintan Boyle
	 */
	public class SharedAssetMain extends MovieClip 
	{
		internal var url:String;
		private const baseUrl:String = "shared_assets/xml/";
		private var localeModel:LocaleModel;
		
		public function SharedAssetMain() 
		{
			localeModel = ModelLocator.getInstance().localeModel;			
		}
		
		internal function load():void {
			var service:HttpService = new HttpService();
			service.addEventListener(ServiceEvent.RESULT, service_onResult);
			service.addEventListener(ServiceEvent.FAULT, service_onFault);
			service.method = URLRequestMethod.GET;
			service.url = baseUrl+url;
			service.send();	 
		}
		
		private function service_onFault(e:ServiceEvent):void 
		{
			Debugger.traceOut("service_onFault");
		}
		
		private function service_onResult(e:ServiceEvent):void 
		{
			Debugger.traceOut("service_onResult");			
			localeModel.addLabels(XML(e.data));
		}
	}
	
}